/*
 * @Author: jingzi 1163478123@qq.com
 * @Date: 2025-04-29 20:24:19
 * @LastEditors: jingzi 1163478123@qq.com
 * @LastEditTime: 2025-06-25 20:10:13
 * @Description: 打包配置
 * Copyright (c) 2025 by ${git_name}, All Rights Reserved.
 */
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { crx } from '@crxjs/vite-plugin'
import manifest from './src/manifest.json'
import manifestDev from './src/manifest.dev.json'
import { resolve } from 'path'

const isDev = process.env.NODE_ENV === 'development'

export default defineConfig({
  plugins: [
    vue(),
    crx({ 
      manifest: isDev ? manifest : manifest, 
      watchFile: true 
    })
  ],
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true, // 可以添加全局 Less 变量
        additionalData: `@import "${resolve(__dirname, 'src/styles/index.less')}";`
      }
    }
  },
  build: {
    rollupOptions: {
      input: {
        popup: resolve(__dirname, 'popup.html'),
        content: resolve(__dirname, 'src/content/index.js'),
        // gitlab: resolve(__dirname, 'src/gitlab/index.js'),
        // config: resolve(__dirname, 'src/config/index.js'),
        background: resolve(__dirname, 'src/background/index.js'),
        sidepanel: resolve(__dirname, 'sidepanel.html'),
        options: resolve(__dirname, 'options.html'),
        // styles: resolve(__dirname, 'src/styles/index.less')
      }
    }
  }
}) 